<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改用户')" />
	<th:block th:include="include :: select2-css" />
</head>
<body>
    <div class="form-content">
        <form id="form-user-edit" class="form-horizontal">
            <input name="id" type="hidden" id="treeId" th:value="${carousel.id}"/>
            <h4 class="form-header h4">轮播图信息</h4>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label"><span style="color: red; ">*</span>轮播名称：</label>
                        <div class="col-sm-8">
                            <input name="name" autocomplete="off" placeholder="请输入轮播名称" th:value="${carousel.name}" class="form-control" type="text" maxlength="30" required>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label"><span style="color: red; ">*</span>轮播链接：</label>
                        <div class="col-sm-8">
                            <input name="url" autocomplete="off" placeholder="请输入轮播连接" th:value="${carousel.url}" class="form-control" type="text"  required>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label"><span style="color: red; ">*</span>轮播图片：</label>
                        <div class="col-sm-8">
                            <input name="picture" autocomplete="off" placeholder="请输入图片链接" th:value="${carousel.picture}" class="form-control" type="text"  required>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">状态：</label>
                        <div class="col-sm-8">
                            <label class="toggle-switch switch-solid">
                                <input type="checkbox" id="status"  th:checked="${carousel.enable}">
                                <span></span>
                            </label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label"><span style="color: red; ">*</span>排序：</label>
                        <div class="col-sm-8">
                            <input name="weight" placeholder="请输入序号" th:value="${carousel.weight}" autocomplete="off" class="form-control required" type="text" maxlength="30" required>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="$.modal.close()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
	<script type="text/javascript">
        var prefix = ctx + "system/user";


        $("#form-user-edit").validate({
            onkeyup: false,
            rules:{
                name:{
                    required:true
                },
                picture:{
                    required:true
                },
                url:{
                    required:true
                },
                weight:{
                    required:true
                },
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = $("#form-user-edit").serializeArray();
                var status = $("input[id='status']").is(':checked') == true ? 1 : 0;
                data.push({"name": "enable", "value": status});
                $.operate.save("/carousel/edit", data);
            }
        }
    </script>
</body>
</html>